<include file="public@header"/>
<style type="text/css">

    .p_title {
        width: 515px;
        margin: 0 0 45px 60px;
        padding: 10px 0 10px 20px;
    }

    tr td input,tr td select{ max-width:100%;width:auto;}
    /*tr td input,tr td select{ max-width:80px;width:auto;}*/
    .content_nav .check_info{flex:1; display:flex;flex-direction: column;align-items: center;justify-content: center;}

    .form-control{
        /*width:100% !important; display:inline-block;*/
    }
    .free .form-group{
        margin-top: 30px;}
    .free .form-group input{
        width: 150px;}
</style>
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li><a href="{:url('orders/visua')}">{:lang('可视化墓区')}</a></li>
        <li><a href="{:url('orders/sale')}?order_id={$order_id}">墓位信息</a></li>
        <li><a href="{:url('orders/applyer')}?order_id={$order_id}">申请人信息</a></li>
        <li><a href="{:url('chooseGoods')}?order_id={$order_id}">商品选购</a></li>
        <li><a href="{:url('orders/signContract')}?order_id={$order_id}">合同签订</a></li>
        <li class="active"><a href="{:url('orders/orderPay')}?order_id={$order_id}">订单支付</a></li>

    </ul>
    <form class="form-horizontal  " action="{:url('orderPay')}" method="post" enctype="multipart/form-data">
        <fieldset>
            <!--改版画面-->
            <div class="div_title"><span>客户概览</span></div>
            <div class="control-group1-p div_content">
                <div class="form-group">
                    <label class="control-label ">客户姓名</label>
                    <div class="col-lg-2">
                        <input type="text"  class="form-control" value="{$customer.buyer_name}" disabled>
                    </div>
                    <label class="control-label ">持证类型</label>
                    <div class="col-lg-2" >
                        <input type="text" class="form-control" value="{:cart_type('cart',$customer.cart_type)}" disabled>
                    </div>
                    <label class="control-label ">证件号码</label>
                    <div class="col-lg-2" >
                        <input type="text"  class="form-control" value="{$customer.customer_account}" disabled>
                    </div>
                    <label class="control-label "  >联系电话</label>
                    <div class="col-lg-2">
                        <input type="text"  class="form-control" value="{$customer.buyer_phone}" disabled>
                    </div>
                </div>

                <div class="form-group" >
                    <label class="control-label ">联系地址</label>
                    <div class="col-lg-6" style="width: 41%;" >
                        <input type="text"   class="form-control"  style="width: 90%;" value="{$customer.customer_address}" disabled>
                    </div>
                    <label class="control-label w100">合同编号</label>
                    <div class="col-lg-2" >
                        <input type="text" name="user_login" class="form-control" value="{$result.contract_sn}" disabled>
                    </div>
                    <label class="control-label ">墓位编号</label>
                    <div class="col-lg-2" >
                        <input type="text" name="user_login" class="form-control" value="{$result.tomb_num}" disabled>
                    </div>
                </div>
                <div class="form-group" >
                    <label class="control-label ">具体位置</label>
                    <div class="col-lg-2" style="width: 41%;">
                        <input type="text" name="user_login" class="form-control" style="width: 90%;" value="{$result.tomb_region}" disabled>
                    </div>
                    <label class="control-label w100">当前状态</label>
                    <div class="col-lg-2">
                        <input type="text" name="user_login" class="form-control" value="{$result.pro_status}" disabled>
                    </div>
                    <label class="control-label w100" >格位规制</label>
                    <div class="col-lg-2">
                        <input type="text" name="user_login" class="form-control" value="双穴" disabled>
                    </div>
                </div>

                <div class="row" style="margin: 0;padding: 0;" >
                    <div class="col-md-6">
                        <div class="row">
                            <div class="col-md-12" style="padding: 0 5px 10px 10px;">
                                <div class="box box-info">
                                    <div class="box-header" style="border: 2px solid #0b7ebf;overflow:hidden; overflow-x:auto;">
                                        <div class="div_title" ><span>交款记录</span></div>
                                    </div>

                                    <div class="box-body" style="padding-top:0; height: 225px; border: 2px solid #0b7ebf;overflow:hidden; overflow-x:auto;" >
                                        <table class="table table-hover table-bordered" style="max-width:120% !important;width:120% !important">
                                            <thead>
                                            <tr>
                                                <th>定金单号</th>
                                                <th>类型</th>
                                                <th>付/退款人姓名</th>
                                                <th>付/退款人时间</th>
                                                <th>金额</th>
                                                <th>付/退款人方式</th>
                                                <th>经办人</th>
                                            </tr>
                                            </thead>
                                            <tbody>
                                            <foreach name="deposit" item="vo">
                                                <tr>
                                                    <td >{$vo.pay_sn}</td>
                                                    <td >
                                                        <!--<if condition="$vo.refund_state eq 0"> -->定金
                                                        <!--<else />  -->退金
                                                        <!--</if>-->  </td>
                                                    <td >{$vo.real_name}</td>
                                                    <td >{$vo.add_time|date='Y-m-d H:i:s'}</td>
                                                    <td >{$vo.deposit_price}</td>
                                                    <td >{:cart_type('pay',$vo.pay_type)}</td>
                                                    <td >{:cmf_get_admin_name($vo.handle)}</td>
                                                </tr>
                                            </foreach>
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-12" style="padding: 0 5px 5px 10px;">
                                <div class="box box-info">
                                    <div class="box-header" style="border: 2px solid #0b7ebf;overflow:hidden; overflow-x:auto;">
                                        <div class="div_title" ><span>结算项目</span></div>
                                    </div>
                                    <div class="box-body" style="padding-top:0; border: 2px solid #0b7ebf;overflow:hidden; overflow-x:auto;" >
                                        <div class="div_title" id="div_title" style="width:120%;   background:#DEDDDD;box-shadow: 5px -5px 3px #CFCECE inset;"><span style="color:#222;">墓穴销售</span></div>
                                        <div class="div_titleinfo" style="width:100%;display: ;">
                                                <table class="table table-hover table-bordered" style="max-width:120% !important;width:120% !important">
                                                    <thead>
                                                    <tr>
                                                        <th>墓位编号</th>
                                                        <th>类型</th>
                                                        <th>流程</th>
                                                        <th>单位</th>
                                                        <th>数量</th>
                                                        <th>价格</th>
                                                        <th>下单时间</th>
                                                        <th>导购员</th>
                                                        <th>代理商</th>
                                                        <th>抵顶人</th>
                                                    </tr>
                                                    </thead>
                                                    <tbody>
                                                    <tr>
                                                        <td >{$result.tomb_num}</td>
                                                        <td >
                                                            <!--<if condition="$result.tomb_type eq 1"> -->商品葬
                                                            <!--<elseif condition="$result.tomb_type eq 2" /> -->艺术墓
                                                            <!--<elseif condition="$result.tomb_type eq 3" /> -->生态墓
                                                            <!--<elseif condition="$result.tomb_type eq 4" /> 节地目 （寄存，壁墓）-->
                                                            <!--<if condition="$result.tomb_typei eq 0"> -->壁墓
                                                            <!--<elseif condition="$result.tomb_typei eq 1" /> -->寄存
                                                            <!--</if>-->
                                                            <!--</if>-->
                                                        </td>
                                                        <td > <if condition=" $result.tomb_num eq 0">购买 <else/>寄存 </if></td>
                                                        <td >套</td>
                                                        <td >1</td>
                                                        <td >{$result.selling_price}</td>
                                                        <td >{$result.add_time}</td>
                                                        <td >{:cmf_get_admin_name($result.shoppingguide)}</td>
                                                        <td >{:cmf_get_admin_name($result.agent_user)}</td>
                                                        <td >{$result.reacher}</td>
                                                    </tr>
                                                    </tbody>
                                                </table>
                                        </div>
                                        <div class="div_title" id="div_title1" style="width:120%; background:#DEDDDD;box-shadow:5px -5px 3px #CFCECE inset;"><span style="color:#222;">商品销售</span></div>
                                        <div class="div_titleinfo1 disappear" style=" display:none;">
                                            <form action="{:url('Rock/order')}" method="post">
                                                <table class="table table-hover table-bordered" style="max-width:120% !important;width:120% !important">
                                                    <thead>
                                                    <tr>
                                                        <th>序号</th>
                                                        <th>项目名称</th>
                                                        <th>大类</th>
                                                        <th>类型</th>
                                                        <th>单位</th>
                                                        <th>单价</th>
                                                        <th>数量</th>
                                                        <th>优惠</th>
                                                        <th>销售</th>
                                                        <th>合计</th>
                                                    </tr>
                                                    </thead>
                                                    <tbody id="goods_js">
                                                    <foreach name="goods_arr" item="vos">
                                                        <tr  >
                                                            <input type="hidden" name="goods[{$vos.id}][id]" value="{$vos.id}">
                                                            <td >{$key+1}</td>
                                                            <td >{$vos.goods_name}</td>
                                                            <td >{$vos.cate_name}</td>
                                                            <td > </td>
                                                            <td > </td>
                                                            <td >{$vos.goods_price}</td>
                                                            <td >{$vos.num}</td>
                                                            <td >
                                                                <select name="goods[{$vos.id}][discount_price]" class="discount_price">
                                                                    <option value="0">无</option>
                                                                    <option value="0.95">5%</option>
                                                                    <option value="0.9">10%</option>
                                                                    <option value="0.85">15%</option>
                                                                </select>
                                                            </td>
                                                            <td >{:cmf_get_admin_name($vos.add_user)}</td>
                                                            <input type="hidden" name="goods[{$vos.id}][total_price]" class="g_total_price" value="{$vos.total_price}">
                                                            <td >{$vos.total_price}</td>
                                                        </tr>
                                                    </foreach>
                                                    </tbody>
                                                </table>
                                            </form>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="col-lg-6 free">
                        <div class="box box-info">
                            <div class="box-header" style="border: 2px solid #0b7ebf;overflow:hidden; overflow-x:auto;">
                                <div class="div_title" ><span>费用信息</span></div>
                            </div>
                            <div class="box-body" style="padding-top:0; border: 2px solid #0b7ebf;overflow:hidden; overflow-x:auto;" >
                                <div class="form-group" >
                                    <label class="control-label">销售合计</label>
                                    <div class="col-lg-3" >
                                        <input type="hidden" name="tom_price" class="form-control " value="{$result.sales_total}"  >
                                        <input type="text"   class="form-control" value="{$result.sales_total}" disabled>元
                                    </div>
                                    <label class="control-label">优惠金额</label>
                                    <div class="col-lg-3" >
                                        <input type="text" id="discount_ratio"    disabled class="form-control" >
                                        <input type="hidden" id="discount_ratio_" name="discount_rate" value="{$result.discount_ratio}" >
                                        <input type="hidden"  name="free_price" value="0" >
                                    </div>
                                </div>
                                <div class="form-group" >
                                    <label class="control-label">购墓合计</label>
                                    <div class="col-lg-3" >
                                        <input type="hidden" name="total_price" class="form-control"  value="{$result.total_price}" >
                                        <input type="text" disabled name="total_price" class="form-control"  value="{$result.total_price}" >元
                                    </div>
                                    <label class="control-label">减免金额</label>
                                    <div class="col-lg-3" >
                                        <input type="hidden" name="free_price" class="form-control"  value="{$result.free_price}" >
                                        <input type="text" disabled name="free_price" class="form-control"  value="{$result.free_price}" >元
                                    </div>
                                </div>
                                <div class="form-group" >
                                    <label class="control-label">另收费项目</label>
                                    <div class="col-lg-3" >
                                        <input type="hidden"  name="pay_service_price"   value=" {$result.pay_service_price}"  >
                                        <input type="text"  class="form-control pay_service_price"  value="{$result.pay_service_price}" disabled>元
                                    </div>
                                    <label class="control-label" >合计应收金额</label>
                                    <div class="col-lg-3" >
                                        <input type="hidden"  class="deal_price" name="deal_price"  value="{$result.closing_price}"  >
                                        <input type="text"  class="form-control deal_price_"  value="￥{$result.closing_price}" disabled>元
                                    </div>
                                </div>
                                <div class="form-group" >
                                    <label class="control-label">预付款</label>
                                    <div class="col-lg-3"  >
                                        <input type="hidden" class="deposit_price"  name="deposit_price" value="{$result.deposit_price}" >
                                        <input type="text"  class="form-control deposit_price_"  value="￥{$result.deposit_price}" disabled>元
                                    </div>
                                    <!--<label class="control-label" >二次付款</label>
                                    <div class="col-lg-3" >
                                        <input type="hidden" class="deposit_price_two"  name="deposit_price_two" value="{$result.deposit_price_two|default='0'}"  >
                                        <input type="text"  class="form-control deposit_price_two_"  value="0 " disabled>元
                                    </div>-->
                                    <label class="control-label" >应收金额</label>
                                    <div class="col-lg-3" >
                                        <input type="hidden" class="total_price"  name="total_price" value=" " >
                                        <input type="text"  class="form-control total_price_"   disabled>元
                                    </div>
                                </div>
                                <div class="form-group" >
                                    <label class="control-label" >付款人</label>
                                    <div class="col-lg-3" >
                                        <input type="text"  name="real_name" class="form-control"  value="{$customer.buyer_name}">
                                    </div>
                                    <label class="control-label">付款人手机号</label>
                                    <div class="col-lg-3" style=" ">
                                        <input type="text"  name="real_phone" class="form-control" value="{$customer.buyer_phone}"  placeholder="请输入付款人手机号">
                                    </div>
                                </div>
                                <div style="float:left; width:90%; margin-left:6%;border-bottom:1px dashed;margin-bottom:20px;"></div>
                                <div class="form-group" >
                                        <label class="control-label" style="">商品合计</label>
                                        <div class="col-lg-3" >
                                            <input type="hidden" class="goods_price" name="goods_price"  value="{$goods_total_price}" >
                                            <input type="text" class="form-control goods_price_"  style="width: 150px" value="￥{$goods_total_price}" disabled>元
                                        </div> 
                                    <label class="control-label" >付款方式</label>
                                    <div class="col-lg-3"  >
                                        <select name="pay_type"   class="form-control">
                                            <option value="1">现金</option>
                                            <option value="2">转账</option>
                                            <option value="3">电汇</option>
                                            <option value="4">微信</option>
                                            <option value="5">支付宝</option>
                                            <option value="6">其他</option>
                                        </select>
                                    </div>
                                </div>
                                <div style="float:left; width:90%; margin-left:6%;border-bottom:1px dashed;margin-bottom:20px;"></div>
                                <div class="form-group" >
                                    <label class="control-label">收银备注</label>
                                    <div class="col-lg-7" style=" ">
                                        <textarea rows="3" name="remark" style="width: 90%" class="form-control" ></textarea>
                                    </div>
                                </div>
                                <div class="form-group" >
                                    <label class="control-label" >付款时间</label>
                                    <div class="col-lg-3" >
                                        <input type="text" name="add_time" class="form-control js-date"    value='{$result.payaddtime}'>
                                    </div>
                                    <label class="control-label" style="">收款人</label>
                                    <div class="col-lg-3" >
                                        <input type="text"   class="form-control"  value="{:cmf_get_admin_name()}" disabled>
                                    </div>
                                </div>

                                <div class="form-group" >
                                    <div class="col-lg-12" >
                                        <label class="control-label" style=""> </label>
                                        <input type="hidden" name="pay_id"   value="{$pay_info.id|default=''}">
                                        <input type="hidden" name="tomb_type"   value="2">
                                        <input type="hidden" name="dtype" id="otype" value="">
                                        <input type="hidden" name="order_id" value="{$result.order_id|default=''}">
                                        <input type="hidden" name="tomb_id" value="{$result.tomb_id|default=''}">
                                        <input type="hidden" name="tomb_num" value="{$result.tomb_num|default=''}">
                                        <input type="hidden" name="customer_id" value="{$result.customer_id|default=''}">
                                        <div class="btn btn-primary" id="check-save">保存</div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </fieldset>
    </form>
</div>
<script type="text/javascript" src="__STATIC__/js/admin.js?v={:time()}"></script>
<script type="text/javascript">
    $(function () {
        //-----商品价格计算-----------
        goods_price_count()
         //-----end ----------------
        var discount_ratio_= (1-$('#discount_ratio_').val())*100;
        $('#discount_ratio').val(100-discount_ratio_+'折');
        $('.deposit_price_two_').val('￥'+$('.deposit_price_two').val());

        var receivable_price = Number(Number($('.deal_price').val().replace(/,/g, "")).toFixed(2)*1 -
            Number($('.deposit_price').val().replace(/,/g,"")).toFixed(2)*1 );
        $('.total_price').val(receivable_price);
        $('.total_price_').val('￥'+receivable_price.toFixed(2));
    });
    
    $('.discount_price').change(function () {
        var yh =  $(this).val();
        var goods_price =  $(this).parent().parent().find('td:eq(5)').text();;
        var goods_num =  $(this).parent().parent().find('td:eq(6)').text();
        var count_goods_price = goods_price *goods_num;
        if (yh!=0){
            count_goods_price = (goods_price *goods_num) * yh;
        }
        var goods_price_num = Number(Number(count_goods_price).toFixed(2)*1);

        $(this).parent().parent().find('td:eq(9)').text(goods_price_num);
        $(this).parent().parent().find('.g_total_price').val(goods_price_num);

        goods_price_count()

    })

    function goods_price_count(){
        var goods_price_num =0;
        $("#goods_js tr").each(function (i,n) {
            var goods_price = $(this).find('td:eq(5)').text();
            var goods_num = $(this).find('td:eq(6)').text();
            var yh =  $(this).find('select').eq(0).children(':selected').val();
            var count_goods_price = goods_price *goods_num;
            if (yh!=0){
                count_goods_price = (goods_price *goods_num) * yh;
            }
            goods_price_num += Number(Number(count_goods_price).toFixed(2)*1);
        })
        console.log(goods_price_num)
        $('.goods_price').val(goods_price_num);
        $('.goods_price_').val('￥'+goods_price_num);
    }

    // 提交保存
    $("#check-save").click(function(){
        $("#otype").val(1);
        $.post($(".form-horizontal").attr('action'), $(".form-horizontal").serialize(), function(result){
            if(result.code == 1){
                layer.confirm(result.msg, {
                    icon: 1, btn: ['确认']
                    , btn1: function () {
                        window.location.href = result.url;
                    }
                });
            } else {
                layer.alert(result.msg, { icon: 5 });
            }
        }, 'json');
    });

    $("#div_title").click(function(){
        if($(".div_titleinfo").is(":hidden")){
            $(".div_titleinfo").show();
        }else{
            $(".div_titleinfo").hide();
        }
    })
    $("#div_title1").click(function(){
        if($(".div_titleinfo1").is(":hidden")){
            //
            $(".div_titleinfo1").show();
        }else{
            $(".div_titleinfo1").hide();
        }
    })
</script>
</body>
</html>